﻿var arr = new Array();
var hiddenName;
var viewName;
var arrText = new Array();
			Ext.onReady(function(){
				
				Ext.form.Field.prototype.msgTarget = 'side';
				Ext.QuickTips.init();
	
				
				var tree=new Ext.tree.TreePanel({
					xtype:'treepanel',
					autoScroll :true,
					rootVisible :false,
					checkModel: "single" ,
					root:new Ext.tree.AsyncTreeNode(
							{lid:0,text:'构件库',leaf:false}
					),
					
					loader: new Ext.tree.TreeLoader({
						dataUrl:'cognos/loadTreeAction.do?action=loadTreeChecked',
						listeners : {
							'beforeload' : function(loader,node) {
								loader.baseParams.id=node.id
							}
						}
					})
				});
tree.on('checkchange', function(node, checked) {   
		node.expand();
		node.attributes.checked = checked;   
		  
	}, tree); 
	

 var upwindows = new Ext.FormPanel({    	
	    labelAlign: 'right',  
	    buttonAlign:'right', 
	    autoHeight:true,
	    bodyStyle:'padding:5px',            
	    frame:true,    
	    labelWidth:80,
	    fileUpload: true, 
	    frame:true,  
	    items:tree            	
	});		
 upwin =  new Ext.Window({
			title:'菜单列表',
	        width:300,
			// autoWidth:true,
	        height:250,
	        autoHeight:true,
	        minWidth: 300,
	        minHeight: 200,
	        layout: 'fit',
	        plain:true,
	        maximizable:true,
	        bodyStyle:'padding:5px;',
	        buttonAlign:'center',	
	        closeAction:'hide',
	        items : upwindows 
        }); 
        
sButton = upwin.addButton({
				text: '新增',
				handler:function(){
				var a=tree.getChecked();

				if( a.length > 1 || a.length <= 0 ){
					Ext.Msg.alert("提示","请选择一个父节点！");
					return;
				}
				var nid = a[0].attributes.id;
				Ext.MessageBox.confirm("请确认","是否新增节点？",function(button,text){
					if(button=="yes"){
						document.location.href = "cognos/loadTreeAction.do?action=redirectPage&nid="+nid ;
						upwin.hide();
					}
				});
				}});
cButton = upwin.addButton({
				text: '关闭',
				handler:function(){
					upwin.hide();
				}});


});
function AddDeptTreeCustom(hiddenName,viewName){
	this.hiddenName=hiddenName;
	this.viewName=viewName;
	upwin.show();
}
function AddDeptTree(){
	upwin.show();
}

